/*
 * CastBooleanAst.cpp
 *
 *  Created on: 19 Nov 2010
 *      Author: kn308
 */

#include <MAlice/Ast/CastBooleanAst.h>
#include <MAlice/Codegen.h>

namespace MAlice
{

CastBooleanAst::CastBooleanAst(ExpressionAst* value) :
	mValue(value)
{
}

CastBooleanAst::~CastBooleanAst()
{
}

llvm::Value* CastBooleanAst::generate()
{
	Codegen* g       = Codegen::get();
	Builder* builder = g->getBuilder();

	builder->CreateIntCast(mValue->generate(),
			Type::getInt1Ty(g->getContext()),
			true,
			"<bool>");
}

}
